package com.jinyu.admin.service.sys.impl;

import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.IdUtil;
import com.jinyu.admin.service.sys.SysDictTypeService;
import com.jinyu.dao.entity.sys.SysDictType;
import com.jinyu.dao.mapper.sys.SysDictTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: yangli
 * @Despriction:
 * @Package: com.jinyu.admin.service.sys.impl
 * @Date:Created in 2022/5/7 13:31
 * @Modify By:
 */
@Service
public class SysDictTypeServiceImpl implements SysDictTypeService {

    @Autowired
    private SysDictTypeMapper sysDictTypeMapper;

    @Override
    public int insert(SysDictType sysDictType) {
        StpUtil.checkLogin();
        String loginId = StpUtil.getLoginIdAsString();
        sysDictType.setId(IdUtil.getSnowflakeNextId());
        sysDictType.setCreateUser(loginId);
        sysDictType.setUpdateUser(loginId);
        return sysDictTypeMapper.insert(sysDictType);
    }

    @Override
    public int delete(long id) {
        return sysDictTypeMapper.delete(id);
    }

    @Override
    public int update(SysDictType sysDictType) {
        return sysDictTypeMapper.update(sysDictType);
    }

    @Override
    public SysDictType selectByOne(long id) {
        return sysDictTypeMapper.selectByOne(id);
    }

    @Override
    public List<SysDictType> pageList(int offset, int pagesize) {
        return sysDictTypeMapper.pageList(offset,pagesize);
    }
}
